class Message
  attr_reader :user, :content

  def initialize(user, target, content, nick)
    @nick = nick
    @user = user
    @target = target
    @content = content
    @timestamp = %x{date}.chop
  end

  def index(pattern)
    return @content.index(pattern)
  end

  def to_s()
    return "#{@timestamp}\t\e[1;32m#{@user}\e[0m: #{@content}" if (@target[0] == ?# and !(@content =~ /#{@nick}/))
    return "\e[1;34m#{@timestamp}\t#{@user}\e[0m: \e[1;32m#{@content}\e[0m" if (@target[0] == ?# and @content =~ /#{@nick}/)
    return "\e[1;34m#{@timestamp}\t#{@user} (PRIVATE MSG)\e[0m: \e[1;32m#{@content}\e[0m" if (@target[0] != ?#)
  end

  def match(regex)
    @content.match(regex)
  end

  def content
    @content
  end

  def logOutput()
    return "#{@timestamp}\t#{@user}: #{@content}"
  end

  def user
    return @user
  end
end


